package cn.wowjoy.pda.android_pharmacy.mvvm.presenter;

import android.util.Log;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import cn.wowjoy.pda.android_pharmacy.common.core.BasePresenter;
import cn.wowjoy.pda.android_pharmacy.common.utils.MyCompare;
import cn.wowjoy.pda.android_pharmacy.common.utils.PreferenceManager;
import cn.wowjoy.pda.android_pharmacy.model.xmlEntity.inHospitalPatientInfo.InHospitalPatientBeen;
import cn.wowjoy.pda.android_pharmacy.mvvm.vm.InHospitalTakeMedicineDetailViewModel;

/**
 * Created by sinyo on 2017/7/25.
 */

public class InHospitalTakeMedicineDetailPresenter extends BasePresenter<InHospitalTakeMedicineDetailViewModel>{
    public ArrayList<InHospitalPatientBeen> FitstData =new ArrayList<>();
    private ArrayList<InHospitalPatientBeen> mTestBeen=new ArrayList<>();
    public String DJJLID;

    @Override
    public void onCreatePresenter() {
        loadData(false);
    }

    @Override
    public void loadData(boolean ref) {
        FitstData.clear();
        List<InHospitalPatientBeen> employeeInfoBeenList = (List<InHospitalPatientBeen>) activity.getIntent().getExtras().getSerializable("inHospitalPatientBeenList");
        DJJLID=activity.getIntent().getExtras().getString("DJJLID");
        if(employeeInfoBeenList != null && employeeInfoBeenList.size() != 0){
            PreferenceManager.getInstance().setHospitalTakeProgressTotal(employeeInfoBeenList.size()+"");
            Collections.sort(employeeInfoBeenList,new MyCompare<InHospitalPatientBeen>());
            FitstData.addAll(employeeInfoBeenList);
            Log.e("PXY", "init: "+FitstData.toString() );
            if(FitstData!=null ){
                viewModel.setWData(FitstData);
            }
        }
    }
}
